import request from '@/config/axios'

export interface ProductVO {
  id: number
  type: number
  name: string
  code: string
}
export interface ProductSkuVO {
  productId: number
  name: string
  num: number
  unit: string
  oldPrice: string
  price: string
  expireTime: number
}
// 查询系统产品列表
export const getProductPage = async (params) => {
  return await request.get({ url: `/system/product/page`, params })
}

// 查询系统产品详情
export const getProduct = async (id?: number) => {
  return await request.get({ url: `/system/product/get?id=${id}` })
}

// 查询系统产品详情
export const getProductByCode = async (code: string) => {
  return await request.get({ url: `/system/product/get-by-code?code=` + code })
}

// 查询系统产品
export const getProductList = async () => {
  return await request.get({ url: `/system/product/list` })
}

// 新增系统产品
export const createProduct = async (data: ProductVO) => {
  return await request.post({ url: `/system/product/create`, data })
}

// 修改系统产品
export const updateProduct = async (data: ProductVO) => {
  return await request.put({ url: `/system/product/update`, data })
}

// 删除系统产品
export const deleteProduct = async (id: number) => {
  return await request.delete({ url: `/system/product/delete?id=` + id })
}

// 导出系统产品 Excel
export const exportProduct = async (params) => {
  return await request.download({ url: `/system/product/export-excel`, params })
}
